package com.zte.claa.inficombo.csa.app.service.rptparse.ext.gnss;

import java.text.SimpleDateFormat;
import java.util.Date;

// HCMonitor服务器解析的数据
public class GNEHResultData {
	public static final String TIME_FORMAT = "yyyy/MM/dd HH:mm:ss";
	
	// 基本属性.
	private String stationId; 	// 测站ID
	private String stationName; // 测站名称
	private String localTime; 	// yyyy/MM/dd HH:mm:ss格式；
	private double lat;  //WGS84坐标纬度；
	private double lon;  //WGS84坐标经度；
	private double x;    //当地坐标系北方向坐标；
	private double y;    //当地坐标系东方向坐标；
	private double H;    //当地坐标系高程；	
	private double fLat; //未滤波的WGS84坐标纬度；
	private double fLon; //未滤波的WGS84坐标经度；
	private double fx;   //未滤波的当地坐标系北方向坐标；
	private double fy;   //未滤波的当地坐标系东方向坐标；
	private double fH;   //未滤波的当地坐标系高程；
	
	// 构建器.
	public GNEHResultData(){
		
	}

	public String getStationId() {
		return stationId;
	}

	public void setStationId(String stationId) {
		this.stationId = stationId;
	}

	public String getStationName() {
		return stationName;
	}

	public void setStationName(String stationName) {
		this.stationName = stationName;
	}

	// 按 yyyy-MM-dd HH:mm:ss格式返回字符串.
	public String getLocalTime() {
		return localTime.replaceAll("/", "-");
	}

	public void setLocalTime(String localTime) {
		this.localTime = localTime;
	}

	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLon() {
		return lon;
	}

	public void setLon(double lon) {
		this.lon = lon;
	}

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	public double getH() {
		return H;
	}

	public void setH(double h) {
		H = h;
	}

	public double getfLat() {
		return fLat;
	}

	public void setfLat(double fLat) {
		this.fLat = fLat;
	}

	public double getfLon() {
		return fLon;
	}

	public void setfLon(double fLon) {
		this.fLon = fLon;
	}

	public double getFx() {
		return fx;
	}

	public void setFx(double fx) {
		this.fx = fx;
	}

	public double getFy() {
		return fy;
	}

	public void setFy(double fy) {
		this.fy = fy;
	}

	public double getfH() {
		return fH;
	}

	public void setfH(double fH) {
		this.fH = fH;
	}
	
	/**
	 * 解析上报的当地时间.
	 * 
	 * @return
	 * @throws Exception
	 */
	public Date parseLocalTime() throws Exception {
		SimpleDateFormat sdf = new SimpleDateFormat(TIME_FORMAT);
		return sdf.parse(this.localTime);		
	}
	
	/**
	 * 解析GNSS服务器的响应结果（逗号分隔的Ascii字符串）
	 * 
	 * @param rsp
	 * @return
	 */
	public static GNEHResultData parseRspData(String rsp) {
		if(rsp == null || rsp.trim().equals("")){
			return null;
		}
		String[] attrValues = rsp.split(",");
		if(attrValues.length < 14){
			return null;
		}		
		GNEHResultData gnssRsp = new GNEHResultData();
		gnssRsp.setStationId(attrValues[1].trim());
		gnssRsp.setStationName(attrValues[2].trim());
		gnssRsp.setLocalTime(attrValues[3].trim());
		gnssRsp.setLat(Double.parseDouble(attrValues[4].trim()));
		gnssRsp.setLon(Double.parseDouble(attrValues[5].trim()));
		gnssRsp.setX(Double.parseDouble(attrValues[6].trim()));
		gnssRsp.setY(Double.parseDouble(attrValues[7].trim()));
		gnssRsp.setH(Double.parseDouble(attrValues[8].trim()));
		gnssRsp.setfLat(Double.parseDouble(attrValues[9].trim()));
		gnssRsp.setfLon(Double.parseDouble(attrValues[10].trim()));
		gnssRsp.setFx(Double.parseDouble(attrValues[11].trim()));
		gnssRsp.setFy(Double.parseDouble(attrValues[12].trim()));
		gnssRsp.setfH(Double.parseDouble(attrValues[13].trim()));
		return gnssRsp;
	}
}
